package com.ruoyi.internet.service.impl;

import cn.hutool.core.util.IdUtil;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.core.utils.SecurityUtils;
import com.ruoyi.internet.domain.IntEntrust;
import com.ruoyi.internet.mapper.IntEntrustMapper;
import com.ruoyi.internet.service.IIntEntrustService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 委托办理Service业务层处理
 *
 * @author cjie
 * @date 2021-08-16
 */
@Service
public class IntEntrustServiceImpl implements IIntEntrustService {
    @Autowired
    private IntEntrustMapper intEntrustMapper;

    /**
     * 查询委托办理
     *
     * @param id 委托办理ID
     * @return 委托办理
     */
    @Override
    public IntEntrust selectIntEntrustById(String id) {
        return intEntrustMapper.selectIntEntrustById(id);
    }

    /**
     * 查询委托办理列表
     *
     * @param intEntrust 委托办理
     * @return 委托办理
     */
    @Override
    public List<IntEntrust> selectIntEntrustList(IntEntrust intEntrust) {
        return intEntrustMapper.selectIntEntrustList(intEntrust);
    }

    /**
     * 新增委托办理
     *
     * @param intEntrust 委托办理
     * @return 结果
     */
    @Override
    public int insertIntEntrust(IntEntrust intEntrust) {
        intEntrust.setId(IdUtil.getSnowflake(0, 0).nextIdStr());
        intEntrust.setCreateTime(DateUtils.getNowDate());
        intEntrust.setCreateBy(SecurityUtils.getUsername());
        intEntrust.setCreateId(SecurityUtils.getUserId());
        return intEntrustMapper.insertIntEntrust(intEntrust);
    }

    /**
     * 修改委托办理
     *
     * @param intEntrust 委托办理
     * @return 结果
     */
    @Override
    public int updateIntEntrust(IntEntrust intEntrust) {
        intEntrust.setUpdateTime(DateUtils.getNowDate());
        intEntrust.setUpdateBy(SecurityUtils.getUsername());
        return intEntrustMapper.updateIntEntrust(intEntrust);
    }

    /**
     * 批量删除委托办理
     *
     * @param ids 需要删除的委托办理ID
     * @return 结果
     */
    @Override
    public int deleteIntEntrustByIds(String[] ids) {
        return intEntrustMapper.deleteIntEntrustByIds(ids);
    }

    /**
     * 删除委托办理信息
     *
     * @param id 委托办理ID
     * @return 结果
     */
    @Override
    public int deleteIntEntrustById(String id) {
        return intEntrustMapper.deleteIntEntrustById(id);
    }
}
